package com.feng.exma.service.impl;

import com.feng.common.vo.ApiRest;
import com.feng.exma.entity.Exam;
import com.feng.exma.entity.ExamUser;
import com.feng.exma.mapper.ExamUserMapper;
import com.feng.exma.service.ExamUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.feng.security.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author feng
 * @since 2023-03-22 17:35:29
 */
@Service
public class ExamUserServiceImpl extends ServiceImpl<ExamUserMapper, ExamUser> implements ExamUserService {

    @Autowired
    private ExamUserMapper examUserMapper;

    @Override
    public ApiRest<List<Exam>> myExamAll() {
        UserVO userVO = (UserVO) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        List<Exam> exams = examUserMapper.myExamAll(userVO.getUserId().toString());
        return ApiRest.success(exams);
    }
}
